//
//  AppDelegate.m
//  C8 Energy
//
//  Created by 颜魏 on 2024/10/1.
//

#import "AppDelegate.h"
#import "IQKeyboardManager.h"
#import "CEDeviceListViewController.h"
#import <Bugly/Bugly.h>
#import "CEHomeViewController.h"
#import "BTManager.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] init];
    self.window.frame = [UIScreen mainScreen].bounds;
    [self.window makeKeyAndVisible];
    UINavigationController *nv = [[UINavigationController alloc] initWithRootViewController:[[CEDeviceListViewController alloc] initWithNibName:@"CEDeviceListViewController" bundle:nil]];
//    UINavigationController *nv = [[UINavigationController alloc] initWithRootViewController:[[CEHomeViewController alloc] initWithNibName:@"CEHomeViewController" bundle:nil]];
    self.window.rootViewController = nv;
    [Bugly startWithAppId:@"9c914a09f5"];
    
    [IQKeyboardManager sharedManager].enable = YES;
    [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
    [IQKeyboardManager sharedManager].enableAutoToolbar = YES;

    return YES;
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"RELOAD_BLUETOOTH_LIST" object:nil];
    UINavigationController *nv = (UINavigationController *)self.window.rootViewController;
    if (nv.viewControllers.count > 1) {
        if ([BTManager sharedBTManager].peripheral) {
            [[BTManager sharedBTManager] connectPeripheral:[BTManager sharedBTManager].peripheral];
        }
    }
}


@end
